﻿using System;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Data;

namespace BizControl.Presentation.Infrastructure.Converters
{
  public class BoolToPathConverter : IValueConverter
  {
    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      Path CancelPath;
      Path AcceptPath;
      bool boolValue;

      if (bool.TryParse(value.ToString(), out boolValue) && !boolValue)
      {
        CancelPath = new Path();
        CancelPath.Stretch = Stretch.Fill;
        CancelPath.StrokeLineJoin = PenLineJoin.Round;
        CancelPath.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
        CancelPath.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
        CancelPath.Data = Geometry.Parse("F1 M 10.8646,7.375C 8.65625,6.75 8.21875,7.5625 7.67183,8.29692C 7.12492,9.03133 6.46858,9.68767 6.32275,10.3335C 6.17692,10.9793 6.54158,11.6147 8.66142,13.6198C 10.7813,15.625 14.6563,19 16.5417,20.8646C 18.4271,22.7292 18.3229,23.0833 16.1354,25.9896C 13.9479,28.8958 9.67708,34.3542 7.38542,37.4896C 5.09375,40.625 4.78125,41.4375 5.01392,42.2327C 5.24659,43.0278 6.02443,43.8057 6.78485,44.2744C 7.54526,44.7432 8.28826,44.9028 9.18059,44.6493C 10.0729,44.3958 11.1146,43.7292 13.7959,41.2353C 16.4772,38.7415 20.7982,34.4205 23.2462,32.0872C 25.6941,29.7538 26.2689,29.4082 28.6188,31.8395C 30.9688,34.2708 35.0938,39.4792 37.3542,41.7917C 39.6146,44.1042 40.0104,43.5208 40.4792,42.8854C 40.9479,42.25 41.4896,41.5625 42.1458,40.8125C 42.8021,40.0625 43.5729,39.25 42.2604,36.3438C 40.9479,33.4375 37.5521,28.4375 35.8646,25.1979C 34.1771,21.9583 34.1979,20.4792 36.0417,17.9167C 37.8854,15.3542 41.5521,11.7083 43.2188,9.58333C 44.8854,7.45833 44.5521,6.85417 43.8333,6.15625C 43.1146,5.45833 42.0104,4.66667 40.7292,4.125C 39.4479,3.58333 37.9896,3.29167 36.4479,3.82292C 34.9063,4.35417 33.2813,5.70833 31.2813,7.45833C 29.2813,9.20833 26.9063,11.3542 25.1354,12.1979C 23.3646,13.0417 22.1979,12.5833 19.625,11.3229C 17.0521,10.0625 13.0729,8 10.8646,7.375 Z ");
        return CancelPath;
      }
      else
      {
        AcceptPath = new Path();
        AcceptPath.Stretch = Stretch.Fill;
        AcceptPath.StrokeLineJoin = PenLineJoin.Round;
        AcceptPath.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
        AcceptPath.Fill = new SolidColorBrush(Color.FromArgb(255, 100, 255, 0));
        AcceptPath.Data = Geometry.Parse("F1 M 6.44424,23.1735C 4.10278,22.2816 3.51742,23.1457 2.79268,23.9262C 2.06794,24.7066 1.20383,25.4035 3.39198,29.738C 5.58013,34.0725 10.8205,42.0446 14.5557,46.1004C 18.2909,50.1561 20.5209,50.2955 26.2909,42.3094C 32.0609,34.3234 41.371,18.2119 45.7752,9.98889C 50.1794,1.7659 49.6777,1.4314 47.9772,1.26416C 46.2768,1.09691 43.3777,1.09691 41.4823,1.6544C 39.5868,2.21189 38.695,3.32687 35.1342,7.77854C 31.5734,12.2302 25.3436,20.0185 21.8732,24.1718C 18.4029,28.3252 17.6918,28.8434 15.2876,27.7785C 12.8833,26.7136 8.78571,24.0655 6.44424,23.1735 Z ");
        return AcceptPath;
      }
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      return null;
    }

    #endregion
  }
}
